//参考地址https://www.uviewui.com/js/http.html
const http = uni.$u.http

// post请求，获取菜单
export const postMenu = (params, config = {}) => http.post('/ebapi/public_api/index', params, config)

// get请求，获取菜单，注意：get请求的配置等，都在第二个参数中，详见前面解释
export const getMenu = (data) => http.get('/ebapi/public_api/index', data)

export const postLogin = (username, password = {}) => http.post('/auth/login', username, password)
export const logout = (username, password = {}) => http.delete('/auth/logout', username, password)

// 验证码
export const getVerifyCode = (data) => http.get('/captchaImage',data)
//用户信息
export const getInfo = (data) => http.get('/system/user/getInfo',data)


// 书籍列表
export const getBookList = (data) => http.get('/rest/book/fiction/list',data)
// 书籍章节
export const getChapterList = (data) => http.get('/rest/book/chapter/list',data)
// 章节内容
export const getChapterContent = (data) => http.get('/rest/book/chapter/' + data.id,data)





//示例
// import { postMenu, getMenu } from '/config/api.js';
// // 发出post，假设需要带上token
// postMenu({ custom: { auth: true }}).then(() => {
// }).catch(() =>{
// })

// // await等待，注意与async结合使用
// await postMenu({ custom: { auth: true }})
// // 假设不需要在响应拦截器中自动弹出的toast，以及不想写catch(如果promise中进行reject，但是却没有catch的话会报错)
// postMenu({ custom: { auth: true, toast: false, catch: false }}).then(() => {
// })

// // get请求
// getMenu({ custom: { auth: true }}).then(() => {
// }).catch(() =>{
// })

// // 也可以直接通过uni.$u.post发出请求，注意此处需要写上接口地址
// uni.$u.http.post('/common/menu', { custom: { auth: true }}).then(() => {
// }).catch(() =>{
// })